import { mallApi } from '/api/mall'

Page({
  data: {
    id: 0,
    orderId: 0,
    expresses: [] as ExpressesCallback[],
  },
  async onLoad(options: any) {
    this.setData({ orderId: +options.orderId, id: +options.id })
    this.fetchExpress()
  },
  async fetchExpress() {
    const expresses = await mallApi.getExpressesList(this.data.orderId)
    this.setData({ expresses })
  },
  logisticsDetail(e: WechatMiniprogram.CustomEvent) {
    const info = JSON.stringify(e.currentTarget.dataset.logistics)
    wx.navigateTo({
      url: `/mall/logisticsInfo/logisticsInfo?id=${this.data.id}&info=${info}`,
    })
  },
})
